﻿#if UNITY_EDITOR
using System.Collections.Generic;
using UnityEditor.Animations;


/// <summary>
/// Animator选择资源项
/// </summary>
public class ESF_SkillAnimatorController
{
    /// <summary>
    /// AnimatorController
    /// </summary>
    public AnimatorController animatorController { get; private set; }

    /// <summary>
    /// 参数组
    /// Key:名称
    /// Value:参数
    /// </summary>
    public Dictionary<string, ESF_SkillAnimatorControllerParameter> parameters { get; private set; }

    /// <summary>
    /// Layer组
    /// Key:名称
    /// Value:Layer
    /// </summary>
    public Dictionary<string, ESF_SkillAnimatorControllerLayer> layerNameIndexs { get; private set; }

    /// <summary>
    /// 构造函数
    /// </summary>
    /// <param name="_animatorController">控制器</param>
    public ESF_SkillAnimatorController(AnimatorController _animatorController)
    {
        parameters = new Dictionary<string, ESF_SkillAnimatorControllerParameter>();
        layerNameIndexs = new Dictionary<string, ESF_SkillAnimatorControllerLayer>();
        animatorController = _animatorController;
        parameters.Clear();
        layerNameIndexs.Clear();
        if (animatorController != null)
        {
            if (animatorController.parameters != null)
            {
                foreach (var key in animatorController.parameters)
                {
                    ESF_SkillAnimatorControllerParameter p = new ESF_SkillAnimatorControllerParameter(key);
                    parameters.Add($"{key.name}", new ESF_SkillAnimatorControllerParameter(key));
                }
            }

            if (animatorController.layers != null)
            {
                for (int i = 0; i < animatorController.layers.Length; i++)
                {
                    ESF_SkillAnimatorControllerLayer l = new ESF_SkillAnimatorControllerLayer(animatorController.layers[i], i);
                    layerNameIndexs.Add(l.enLayerNameIndex, l);
                }
            }
        }
    }
}

#endif
